package com.atguigu.chapter04

object TestFor {

  def main(args: Array[String]): Unit = {
    for (i <- 1 to 5) {
      print(i + "")

    }
    println()

    for (i <- 1 until 3) {
      print(i + "")
    }

    println()

    for (i <- 1 until 5 + 1) {
      println("ss" + i)
    }

    for (i <- 1 to 3 if i != 2) {
      println(i + " ")
    }

    for (i <- 1 to 10 by 2) {
      println("i=" + i)
    }

    for (i <- 1 to 3; j <- 1 to 3) {
      println("i=" + i + "j=" + j)
    }

    for {i <- 1 to 3
         j = 4 - i
         } {
      println("i=" + i + "j=" + j)
    }

    println("yield")

    val res = for (i <- 1 to 10) yield {
      i*2
    }
    println(res)

    println("reverse")
    for (i <- 1 to 10 reverse) {
      println(i)
    }
  }

}
